/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package exatrez.quartz;

import com.google.inject.Inject;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.Trigger;
import org.quartz.TriggerUtils;

/**
 *
 * @author Mansur
 */
public class VisitSchedulerManager {
    
    Scheduler scheduler;
    
    @Inject
    public VisitSchedulerManager(Scheduler scheduler){
        this.scheduler = scheduler;
    }
    
    public void start() throws SchedulerException{
        JobDetail visitJob = new JobDetail("visitBatch", "visitEmail_group", CronVisitEmailJob.class);
        Trigger daily = TriggerUtils.makeDailyTrigger("visit_trigger",02,00);
//        Trigger daily = TriggerUtils.makeHourlyTrigger("visit_trigger");    // for testing
//        Trigger daily = TriggerUtils.makeMinutelyTrigger("visit_trigger");  // for development
        scheduler.scheduleJob(visitJob, daily);
//        scheduler.start();
    }
    
    public void shutdown() throws SchedulerException{
        scheduler.shutdown();
    }
    
}
